Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Vrai-Prix8 * File : src/app/api/admin/cost/mappings/[id]/[decision]/route.ts9 * Module : app10 * Repository : https://git.spboucher.ai/vrai-prix11 * Created : 2026-09-0812 * Last Modified : 2026-09-0813 *14 * Author : Simon-Pierre Boucher15 * Position : Professor of Finance16 * Institution : Université du Québec en Outaouais (UQO)17 * Organization : SP Boucher18 * Website : https://spboucher.ai19 * Git : https://git.spboucher.ai20 *21 * Preferred Contact: contact@spboucher.ai22 * Development : dev@spboucher.ai23 * Support : support@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Vrai-Prix — admin méthode du coût : approuver / rejeter une correspondance proposée.43import { NextRequest, NextResponse } from "next/server";44import { adminAuth } from "@/lib/cost/connectors/admin";45import { reviewMapping } from "@/lib/cost/connectors/matching";4647export const runtime = "nodejs";4849export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string; decision: string }> }) {50 const denied = adminAuth(req);51 if (denied) return denied;52 const { id, decision } = await params;53 if (decision !== "approve" && decision !== "reject") return NextResponse.json({ error: "décision : approve | reject" }, { status: 400 });54 const ok = reviewMapping(Number(id), decision === "approve" ? "approved" : "rejected");55 return ok ? NextResponse.json({ ok: true, id: Number(id), status: decision === "approve" ? "approved" : "rejected" }) : NextResponse.json({ error: "mapping introuvable" }, { status: 404 });56}57